<template>
  <div class="flex justify-between h-full">
    <div class="w-80 mr-2">
      <DeptTree class="full-page" @node-clicked="handleNodeClicked" />
    </div>
    <div class="flex-1">
      <DeptTable :key="deptId" :deptId="deptId" :deptName="deptName" />
    </div>
  </div>
</template>

<script setup>
import DeptTree from './components/DeptTree.vue'
import DeptTable from './components/DeptTable.vue'
import { ref } from 'vue'
import { useUserStore } from '@/stores/user'
const userStore = useUserStore() // 获取用户信息
const deptId = ref(userStore.departmentId) // 默认选中当前用户所在部门
const deptName = ref(userStore.departmentName) // 默认选中当前用户所在部门
const handleNodeClicked = (data) => {
  deptId.value = data.department_id
  deptName.value = data.name
}
</script>
